package com.jinmdz.fmis.mapper.mapper;

import org.apache.ibatis.annotations.*;
import com.jinmdz.fmis.mapper.mapper.provider.CoffinCodeProvider;
import com.jinmdz.fmis.mapper.entity.CoffinCodeEntity;

import java.util.ArrayList;

/**
 * 纸棺二维码打印记录表Mapper
 * 
 * @author generator
 * @date 2020-08-23 18:11
 */
public interface CoffinCodeMapper {

    /**
     * 增加CoffinCode
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @InsertProvider(type = CoffinCodeProvider.class, method = "insertCoffinCode")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertCoffinCode(@Param("entity") CoffinCodeEntity entity);

    /**
     * 删除CoffinCode
     * 
     * @param id 主键
     * @param modifiedUserId 修改用户外键
     * @param version 版本号
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Update(" update coffin_code set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForCoffinCode(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改CoffinCode
     * 
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-08-23 18:11
     */
    @UpdateProvider(type = CoffinCodeProvider.class, method = "updateCoffinCode")
    void updateCoffinCode(@Param("entity") CoffinCodeEntity entity);

    /**
     * 查询CoffinCode实体
     * 
     * @param id 主键
     * @return CoffinCodeEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @Select(" select id,deleted,service_item_id,qr_code,print_number,left_number,disable_state,sort,remark,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from coffin_code where id = #{id} and deleted = 0 limit 1 ")
    CoffinCodeEntity getCoffinCodeById(@Param("id") Integer id);

    /**
     * 查询CoffinCode列表
     * 
     * @param entity 数据实体
     * @return CoffinCodeEntity
     * @author generator
     * @date 2020-08-23 18:11
     */
    @SelectProvider(type = CoffinCodeProvider.class, method = "listCoffinCode")
    ArrayList<CoffinCodeEntity> listCoffinCode(@Param("entity") CoffinCodeEntity entity);
}